<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">

		<title>TRANS-INFO</title>
		<meta name="keywords" content="TRANS-INFO">
		<meta name="description" content="TRANS-INFO">

		<link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
		<link href="../css/font-awesome.css?v=4.4.0" rel="stylesheet">
		<link href="../css/animate.css" rel="stylesheet">
		<link href="../css/style.css?v=4.1.0" rel="stylesheet">

		<!-- treegrid -->
		<link href="../css/plugins/treegrid/jquery.treegrid.css" rel="stylesheet" />
	</head>

	<body class="gray-bg">
		<div class="wrapper wrapper-content animated fadeInRight">
			<div class="row">
				<div class="col-sm-12">
					<div class="ibox float-e-margins">
						<div class="ibox-title">
							<h5><i class="fa fa-table"></i> 调用链明细</h5>
							<div class="ibox-tools">
								<a class="collapse-link">
									<i class="fa fa-chevron-up"></i>
								</a>
								<a class="dropdown-toggle" data-toggle="dropdown" href="rpc_list.html#">
									<i class="fa fa-wrench"></i>
								</a>
								<ul class="dropdown-menu dropdown-user">
									<li>
										<a href="rpc_list.html#">选项1</a>
									</li>
									<li>
										<a href="rpc_list.html#">选项2</a>
									</li>
								</ul>

							</div>
						</div>
						<div class="ibox-content">
							<table class="table tree-2 table-bordered table-striped table-condensed">
								<thead>
									<tr>
										<th>方法</th>
										<th>主题</th>
										<th>开始时间</th>
										<th>时长</th>
										<th>类</th>
										<th>API</th>
										<th>实例名</th>
										<th>应用名</th>
									</tr>
								</thead>
								<tbody id="info_tree">
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- 全局js -->
		<script src="../js/jquery.min.js?v=2.1.4"></script>
		<script src="../js/bootstrap.min.js?v=3.3.6"></script>

		<!-- 自定义js -->
		<script src="../js/content.js?v=1.0.0"></script>
		<script src="../js/mine/format.js"></script>

		<!-- 时间框 -->
		<script src="../js/mine/time.js"></script>

		<!-- treegrid js -->
		<script src="../js/plugins/treegrid/jquery.treegrid.bootstrap3.js"></script>
		<script src="../js/plugins/treegrid/jquery.treegrid.js"></script>

		<!-- Page-Level Scripts -->
		<script>
			$(document).ready(function() {
				//				var traceIdP = GetEscapeStr("traceId");
				//				var agentIdP = GetEscapeStr("agentId");
				//				var spanIdP = GetEscapeStr("spanId");
				//				var focusTimestampP = GetEscapeStr("focusTimestamp");
				var rpc = GetEscapeStr("rpc");
				$.get("http://localhost:8041/my/transactionInfo", {
						traceId: GetEscapeStr("traceId"),
						agentId: GetEscapeStr("agentId"),
						spanId: GetEscapeStr("spanId")
					},
					function(rs) {
						var callStack = JSON.parse(rs).callStack;
						$("#info_tree").html("");
						$.each(callStack, function(i, item) {
							var color="";
							if(callStack[i][7] == "") {
								clsType = "treegrid-" + callStack[i][6];
//							} else if(callStack[i][10] == "REMOTE_ADDRESS") {
//								return true;
							} else if(callStack[i][10] == "Tomcat Servlet Process") {
								if (callStack[i][11] == rpc) {
									color = "style='color:green'";
								alert("dsa");	
								}	else {
									
								}
							} else {
								clsType = "treegrid-" + callStack[i][6] + " treegrid-parent-" + callStack[i][7];
							}
							//var aa = (callStack[i][16] / callStack[i][14]) * 100;
							tr = $("<tr class='" + clsType + " "+color+"'><td><div style='width:460px;word-wrap:break-word;'>" + callStack[i][10] +
								"</div></td><td><div style='width:130px;word-wrap:break-word;'>" + callStack[i][11] +
								"</div></td><td><i class='fa fa-clock-o'></i>" + getFormatDate(callStack[i][1]) +
								"area:</td><td class='text-navy'>" + callStack[i][14] + "ms<br>" +
								"self:" + callStack[i][16] +
								"ms</td><td>" + callStack[i][17] +
								"</td><td>" + callStack[i][19] +
								"</td><td>" + callStack[i][20] +
								"</td><td>" + callStack[i][4] + "</td></tr>");
							$("#info_tree").append(tr);
						});
						$('.tree-2').treegrid({
							expanderExpandedClass: 'glyphicon glyphicon-minus',
							expanderCollapsedClass: 'glyphicon glyphicon-plus'
						});
					});

			});
		</script>

	</body>

</html>